package com.lib.utils;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.mzbopen.rightbottommoreview.BottomListenerCallBack;
import com.mzbopen.rightbottommoreview.RightAddMoreHorizontalScrollView;

import java.util.ArrayList;
import java.util.List;

public class RightBottomMoreActivity extends Activity {

    ArrayList<String> list = new ArrayList<String>() {{
        add("这是测试0");
        add("这是测试1");
        add("这是测试2");
        add("这是测试3");
        add("这是测试4");
        add("这是测试5");
        add("这是测试6");
    }};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_right_bottom_more);
        RightAddMoreHorizontalScrollView rbm_s = findViewById(R.id.rbm_s);
        rbm_s.setBottomListenerCallBack(new BottomListenerCallBack() {
            @Override
            public void onBottomListenerCallBack() {
                Toast.makeText(getBaseContext(), "测试跳转", Toast.LENGTH_LONG).show();
            }
        });
        List<View> views = new ArrayList<>();

        for (int i = 0; i < 10; i++) {
            LinearLayout layout = (LinearLayout) LayoutInflater.from(getBaseContext()).inflate(R.layout.item_right_bottom, null);
            layout.setTag(i);
            TextView horse_race_lamp = layout.findViewById(R.id.horse_race_lamp);
            horse_race_lamp.setText("这是第" + i + "个");
            layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Toast.makeText(getBaseContext(), "" + list.get(Integer.parseInt(String.valueOf(layout.getTag()))) + "个的跳转", Toast.LENGTH_LONG).show();

                }
            });
            views.add(layout);
        }

        rbm_s.addContent(views);
    }
}
